const fs = require('fs');
const path = require('path');
var tools = require('../../../libs/tools');
var config = require(tools.rootPath + 'config');
var { connection, pool, model } = require(tools.rootPath + 'libs/model');

var controller = require(tools.rootPath + 'libs/controller.js');
// var redis = require(tools.rootPath + 'libs/redis');

//https://www.npmjs.com/package/ioredis
module.exports = class extends controller {
    constructor() {
        super();
    }
    // async index(req, res) {
    //     return (await redis.get("foo")) + '';
    // }
    // async set(req, res) {
    //     await redis.set("foo", "{}", "EX", 10);
    //     return 'ok';
    // }
    async index(req, res) {
        return 'ok';
    }
    async test(req, res) {
        // let data = await model.select('select * from article limit 3', [], 10, 'redis');
        // let data = await model.find('select * from article where itemid=?', [2], 10, 'redis');
        // let data = await model.column('select title from article', [], 10, 'redis');
        // let data = await model.value('select title from article where itemid=?', [14], 10, 'redis');
        let data = await model.map('select itemid,title from article limit 3', [], 10, 'redis');
        res.send(data);
    }

}